import os
import signal
import sys
VN_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
if VN_ROOT not in sys.path:
    sys.path.append(VN_ROOT)
from vn_local.event import EventEngine
from vn_local.gateway.barbican import BBCGateway
from vn_local.trader.object import CancelAllRequest
from vn_local.trader.constant import Exchange,Product
from vn_local.trader.utility import load_json

coin_name = str(os.getcwd()).split('/')[-1]
connect_bbc_setting = load_json("connect_bbc.json")

if __name__ == '__main__':
    event_engine = EventEngine()
    bbc = BBCGateway(event_engine)
    bbc.connect(connect_bbc_setting)
    symbol = f"{coin_name}-USDT"
    req = CancelAllRequest(symbol=symbol, exchange=Exchange.BTSE, product=Product.SPOT)
    bbc.cancel_all_orders(req)
    os.kill(os.getpid(), signal.SIGTERM)
